package com.xiaoyu.lanling.feature.conversation.viewholder

import `in`.srain.cube.views.list.CubeRecyclerViewAdapter
import android.util.SparseIntArray
import com.xiaoyu.lanling.feature.conversation.model.ConversationListItemBase
import com.xiaoyu.lanling.feature.conversation.model.MainConversationItem

object ConversationListViewHolderManager {

    const val VIEW_TYPE_CONVERSATION = 1

    private val WEIGHTS = SparseIntArray()

    fun bindViewHolder(adapter: CubeRecyclerViewAdapter<*>) {
        adapter.setViewHolderClass(VIEW_TYPE_CONVERSATION, null, MainConversationViewHolder::class.java, 20)
    }

    fun getWeight(item: ConversationListItemBase): Int {
        if (item is MainConversationItem) {
            if (item.isTop) {
                return 2
            }
        }
        return WEIGHTS[item.viewType]
    }

    init {
        WEIGHTS.put(VIEW_TYPE_CONVERSATION, 1)
    }
}